-
Notifications
You must be signed in to change notification settings - Fork 89
bugfix(specialpower): Fix availability of building based special powers #1444
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
bugfix(specialpower): Fix availability of building based special powers #1444
Conversation
…the current frame to make them immediately available
// This means we need to set their available frame to the current frame to make them usable | ||
// The check for a public timer excludes super weapons from the selection criteria | ||
if (getSpecialPowerModuleData()->m_specialPowerTemplate->hasPublicTimer() == FALSE && | ||
getObject()->isKindOf(KINDOF_STRUCTURE) ) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What if a Mod creates this kind of setup on something that is not a structure? Is the KINDOF_STRUCTURE test really necessary?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Infantry don't seem to be affected by this issue, but that could also be because their special powers have been setup in a different way that initialises their special power timer on unit creation.
I still need to double check some powers to make sure they are working still.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I am worried that it could break a Mod with a setup that is not anticipating here. Is testing for just !getSpecialPowerModuleData()->m_specialPowerTemplate->hasPublicTimer()
not enough? If not, why?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not sure yet, i would need to test first, but it was only building based powers that were not working when i did initially check.
Will do some more testing tomorrow.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I am worried that it could break a Mod with a setup that is not anticipating here. Is testing for just
!getSpecialPowerModuleData()->m_specialPowerTemplate->hasPublicTimer()
not enough? If not, why?
so normal unit creation works down this path
// if we're pre-built, start counting down
if( !getObject()->getStatusBits().test( OBJECT_STATUS_UNDER_CONSTRUCTION ) )
{
//A sharedNSync special only startPowerRecharges when first scienced or when executed,
//Since a new modue with same SPTemplates may construct at any time.
if ( getSpecialPowerTemplate()->isSharedNSync() == FALSE )
startPowerRecharge();
}
if a unit has an ability that is instantly available, the reload time being set to zero makes it always available.
If i removed the building check in the code it would actually cause all powers to be instantly available.
When setting breakpoints the only times i see this code get entered is when the above code is not hit. Usually when a building is placed.
i think the reason for this is because a lot of these borken powers use the getSpecialPowerTemplate()->isSharedNSync()
set to true, so only one instance of that power is available, like spy satelite and drone etc.
This PR fixes some issues that cropped up in Generals Online, caused by an earlier fix that was meant to prevent some special power exploits in non retail code. The earlier fix initialises the available frame to max int to prevent some exploits.
Essentially most of the USA special powers stopped working and the battleplans on the strategy center also stopped working.
This PR fixes this by checking if we are a special power module for a building that does not have a public timer, then setting the available frame for the power to the current frame.
The public timer case prevents super weapons from getting their timers reset to zero again and the building check means it only affects building based special powers. These special powers are typically immediately available once the building is constructed and do not have any other form of initialisation code.
TODO